/**
 */
package de.thwildau.tm.moses.abnf.abnf.provider;

import de.thwildau.tm.moses.abnf.abnf.util.AbnfAdapterFactory;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class AbnfItemProviderAdapterFactory extends AbnfAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable
{
  /**
   * This keeps track of the root adapter factory that delegates to this adapter factory.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ComposedAdapterFactory parentAdapterFactory;

  /**
   * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected IChangeNotifier changeNotifier = new ChangeNotifier();

  /**
   * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected Collection<Object> supportedTypes = new ArrayList<Object>();

  /**
   * This constructs an instance.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public AbnfItemProviderAdapterFactory()
  {
    supportedTypes.add(IEditingDomainItemProvider.class);
    supportedTypes.add(IStructuredItemContentProvider.class);
    supportedTypes.add(ITreeItemContentProvider.class);
    supportedTypes.add(IItemLabelProvider.class);
    supportedTypes.add(IItemPropertySource.class);
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.RuleSet} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected RuleSetItemProvider ruleSetItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.RuleSet}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createRuleSetAdapter()
  {
    if (ruleSetItemProvider == null)
    {
      ruleSetItemProvider = new RuleSetItemProvider(this);
    }

    return ruleSetItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.Rule} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected RuleItemProvider ruleItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.Rule}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createRuleAdapter()
  {
    if (ruleItemProvider == null)
    {
      ruleItemProvider = new RuleItemProvider(this);
    }

    return ruleItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.Alternation} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected AlternationItemProvider alternationItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.Alternation}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createAlternationAdapter()
  {
    if (alternationItemProvider == null)
    {
      alternationItemProvider = new AlternationItemProvider(this);
    }

    return alternationItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.Concatenation} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ConcatenationItemProvider concatenationItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.Concatenation}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createConcatenationAdapter()
  {
    if (concatenationItemProvider == null)
    {
      concatenationItemProvider = new ConcatenationItemProvider(this);
    }

    return concatenationItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.Repetition} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected RepetitionItemProvider repetitionItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.Repetition}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createRepetitionAdapter()
  {
    if (repetitionItemProvider == null)
    {
      repetitionItemProvider = new RepetitionItemProvider(this);
    }

    return repetitionItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.Element} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ElementItemProvider elementItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.Element}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createElementAdapter()
  {
    if (elementItemProvider == null)
    {
      elementItemProvider = new ElementItemProvider(this);
    }

    return elementItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.RuleRef} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected RuleRefItemProvider ruleRefItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.RuleRef}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createRuleRefAdapter()
  {
    if (ruleRefItemProvider == null)
    {
      ruleRefItemProvider = new RuleRefItemProvider(this);
    }

    return ruleRefItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.Group} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected GroupItemProvider groupItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.Group}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createGroupAdapter()
  {
    if (groupItemProvider == null)
    {
      groupItemProvider = new GroupItemProvider(this);
    }

    return groupItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.Option} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected OptionItemProvider optionItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.Option}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createOptionAdapter()
  {
    if (optionItemProvider == null)
    {
      optionItemProvider = new OptionItemProvider(this);
    }

    return optionItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.CharVal} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected CharValItemProvider charValItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.CharVal}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createCharValAdapter()
  {
    if (charValItemProvider == null)
    {
      charValItemProvider = new CharValItemProvider(this);
    }

    return charValItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.NumVal} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected NumValItemProvider numValItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.NumVal}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createNumValAdapter()
  {
    if (numValItemProvider == null)
    {
      numValItemProvider = new NumValItemProvider(this);
    }

    return numValItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.BinVal} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected BinValItemProvider binValItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.BinVal}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createBinValAdapter()
  {
    if (binValItemProvider == null)
    {
      binValItemProvider = new BinValItemProvider(this);
    }

    return binValItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.DecVal} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected DecValItemProvider decValItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.DecVal}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createDecValAdapter()
  {
    if (decValItemProvider == null)
    {
      decValItemProvider = new DecValItemProvider(this);
    }

    return decValItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.HexVal} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected HexValItemProvider hexValItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.HexVal}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createHexValAdapter()
  {
    if (hexValItemProvider == null)
    {
      hexValItemProvider = new HexValItemProvider(this);
    }

    return hexValItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.ProseVal} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ProseValItemProvider proseValItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.ProseVal}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createProseValAdapter()
  {
    if (proseValItemProvider == null)
    {
      proseValItemProvider = new ProseValItemProvider(this);
    }

    return proseValItemProvider;
  }

  /**
   * This keeps track of the one adapter used for all {@link de.thwildau.tm.moses.abnf.abnf.Repeat} instances.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected RepeatItemProvider repeatItemProvider;

  /**
   * This creates an adapter for a {@link de.thwildau.tm.moses.abnf.abnf.Repeat}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter createRepeatAdapter()
  {
    if (repeatItemProvider == null)
    {
      repeatItemProvider = new RepeatItemProvider(this);
    }

    return repeatItemProvider;
  }

  /**
   * This returns the root adapter factory that contains this factory.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ComposeableAdapterFactory getRootAdapterFactory()
  {
    return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
  }

  /**
   * This sets the composed adapter factory that contains this factory.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory)
  {
    this.parentAdapterFactory = parentAdapterFactory;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean isFactoryForType(Object type)
  {
    return supportedTypes.contains(type) || super.isFactoryForType(type);
  }

  /**
   * This implementation substitutes the factory itself as the key for the adapter.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Adapter adapt(Notifier notifier, Object type)
  {
    return super.adapt(notifier, this);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object adapt(Object object, Object type)
  {
    if (isFactoryForType(type))
    {
      Object adapter = super.adapt(object, type);
      if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter)))
      {
        return adapter;
      }
    }

    return null;
  }

  /**
   * This adds a listener.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void addListener(INotifyChangedListener notifyChangedListener)
  {
    changeNotifier.addListener(notifyChangedListener);
  }

  /**
   * This removes a listener.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void removeListener(INotifyChangedListener notifyChangedListener)
  {
    changeNotifier.removeListener(notifyChangedListener);
  }

  /**
   * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void fireNotifyChanged(Notification notification)
  {
    changeNotifier.fireNotifyChanged(notification);

    if (parentAdapterFactory != null)
    {
      parentAdapterFactory.fireNotifyChanged(notification);
    }
  }

  /**
   * This disposes all of the item providers created by this factory. 
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void dispose()
  {
    if (ruleSetItemProvider != null) ruleSetItemProvider.dispose();
    if (ruleItemProvider != null) ruleItemProvider.dispose();
    if (alternationItemProvider != null) alternationItemProvider.dispose();
    if (concatenationItemProvider != null) concatenationItemProvider.dispose();
    if (repetitionItemProvider != null) repetitionItemProvider.dispose();
    if (elementItemProvider != null) elementItemProvider.dispose();
    if (ruleRefItemProvider != null) ruleRefItemProvider.dispose();
    if (groupItemProvider != null) groupItemProvider.dispose();
    if (optionItemProvider != null) optionItemProvider.dispose();
    if (charValItemProvider != null) charValItemProvider.dispose();
    if (numValItemProvider != null) numValItemProvider.dispose();
    if (binValItemProvider != null) binValItemProvider.dispose();
    if (decValItemProvider != null) decValItemProvider.dispose();
    if (hexValItemProvider != null) hexValItemProvider.dispose();
    if (proseValItemProvider != null) proseValItemProvider.dispose();
    if (repeatItemProvider != null) repeatItemProvider.dispose();
  }

}
